package com.hc.serviceimpl;

import com.alibaba.fastjson.JSONObject;
import com.hc.entity.Incubatormv;
import com.hc.mapper.IncubatormvMapper;
import com.hc.model.IncubModel;
import com.hc.service.IIncubatormvService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hc.util.DateUtil;
import com.hc.util.EquipmentRecordServiceImplUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author LiuZhiHao
 * @since 2019-12-04
 */
@Service
@Slf4j
public class IncubatormvServiceImpl extends ServiceImpl<IncubatormvMapper, Incubatormv> implements IIncubatormvService {

    @Autowired
    private IncubatormvMapper incubatormvMapper;

    @Override
    public Map<String, List<IncubModel>> selectIncubday(String date) {
        //从数据库查询出当天所有培养箱的,MT700(自身数据),第三方(MT300,mt100),返回一个list集合
        List<Incubatormv> listincub = incubatormvMapper.selectIncubday(date);
        //过滤掉名字为空的
        List<Incubatormv> collect = listincub.stream().filter(s -> StringUtils.isNotEmpty(s.getEquipmentName())).collect(Collectors.toList());
        //将查询到的所有数据进行名称分组.例如,13号培养箱包含(MT700,MT300,MT100),得到一个map<培养箱名称,培养箱模型>集合          //如若修改,可将此修改为getgroup分组,效果一样
        Map<String, List<Incubatormv>> collectIncoub = collect.stream().collect(Collectors.groupingBy(Incubatormv::getEquipmentName));
        //Map<String, List<Incubatormv>> collect = listincub.stream().collect((Collectors.groupingBy(Incubatormv::getEquipmentNo)));
        //下面开始遍历取值,将取出的值放进新的数据模型里面,组合成一条数据,返回给前端
        //假设有N个培养箱,那么我需要循环N次,拿到N个培养箱的名称
        /* List<String> listName = incubatormvMapper.selectIncoubName();*/
        HashMap<String, List<IncubModel>> map = new HashMap<>();
        //获得所有培养箱名称集合
        Collection key = collectIncoub.keySet();
        //将key放入list集合中方便取值
        List<String> list1 = new ArrayList<>(key);

        for (int i = 0; i < list1.size(); i++) {
            //循环一次建立一个List<IncubModel>
            List<IncubModel> list = new ArrayList<>();
            //获取到培养箱的民称,例如 : 13,作为新map的键
            String incubName = list1.get(i);
            //一个培养箱名称,对应的list里面有四个培养箱模型,所以循环四次
            for (int j = 0; j < 4; j++) {
                //每循环一次创建一个新的培养箱模型
                IncubModel incubModel = new IncubModel();
                //每循环一次设置时间区间,一共四个区间,时间区间为共有属性
                incubModel.setTime_interval((j + 1) + "");
                list.add(incubModel);
            }
            //通过培养箱的名字作为键,获取对应的list<IncubModel>,判断其是否为空,为空,则返回前端的是一个培养箱名键,值为空,如果不为空,
            //则说明,此培养箱有相应的数据
            List<Incubatormv> incubatormvslist = collectIncoub.get(incubName);
            if (CollectionUtils.isNotEmpty(incubatormvslist)) {

                for (int n = 0; n < incubatormvslist.size(); n++) {
                    //遍历取出原始数据模型
                    Incubatormv incubatormv = incubatormvslist.get(n);
                    //取出设备属性id判断是否为第三方数据
                    String instrumentTypeId = incubatormv.getInstrumentTypeId();
                    //如果设备属性instrumentTypeId为14,13,12,97表明是设备自身数据
                    if ("14".equals(instrumentTypeId) || "13".equals(instrumentTypeId)
                            || "12".equals(instrumentTypeId) || "97".equals(instrumentTypeId)
                            || "105".equals(instrumentTypeId)) {
                        String timeIntervalz = incubatormv.getTimeInterval();
                        for (int m = 0; m < 4; m++) {
                            String time_interval = list.get(m).getTime_interval();
                            if (time_interval.equals(timeIntervalz)) {
                                list.get(m).setMeanValue(incubatormv.getMeanValue());
                                list.get(m).setHumidityMv(incubatormv.getHumidityMv());
                                list.get(m).setCdMv(incubatormv.getCdMv());
                                list.get(m).setOxygenMv(incubatormv.getOxygenMv());
                            }
                        }
                    }
                    //如果设备属性为1,表明数据为第三方MT100的
                    if ("1".equals(instrumentTypeId) || "2".equals(instrumentTypeId)) {
                        String thirdTimeIntervalMT100 = incubatormv.getThirdTimeInterval();
                        for (int m = 0; m < 4; m++) {
                            String time_interval = list.get(m).getTime_interval();
                            if (time_interval.equals(thirdTimeIntervalMT100)) {
                                list.get(m).setThirdTemperatureMvMT100(incubatormv.getThirdTemperatureMv());
                                list.get(m).setEquipment_no(incubatormv.getEquipmentNo());
                            }
                        }
                    }
                    if ("4".equals(instrumentTypeId) || "5".equals(instrumentTypeId) || "6".equals(instrumentTypeId) || "7".equals(instrumentTypeId)) {
                        //如果设备睡醒为3,表明数据为第三方MT300的
                        String thirdTimeIntervalMt300 = incubatormv.getThirdTimeInterval();
                        for (int m = 0; m < 4; m++) {
                            String time_interval = list.get(m).getTime_interval();
                            if (time_interval.equals(thirdTimeIntervalMt300)) {
                                list.get(m).setThirdTemperatureMvMT300(incubatormv.getThirdTemperatureMv());
                                list.get(m).setThirdCdMv(incubatormv.getThirdCdMv());
                                list.get(m).setThirdYqMv(incubatormv.getThirdYqMv());
                            }
                        }
                    }

                    }
            }
            map.put(incubName, list);
        }
        HashMap<String, List<IncubModel>> map1 = new HashMap<>();
        Set<String> isname = map.keySet();
        String equipment_no = null;
        for (String s : isname) {
            List<IncubModel> incubModelList = map.get(s);
            for (int i = 0; i < incubModelList.size(); i++) {
                equipment_no = incubModelList.get(i).getEquipment_no();
                if(equipment_no!=null){
                    map1.put(equipment_no, incubModelList);
                }
            }
        }
        return map1;
    }




    @Override
    public Map<String, List<IncubModel>> selectIncubmonth(String equipment_no, String startdate, String enddate) {
        //获得培养箱名称
            //得到一个月的所有数据集合
            List<Incubatormv> incubatormvs = incubatormvMapper.selectIncubmonth(equipment_no, startdate, enddate);
            //通过天分组
            Map<String, List<Incubatormv>> collectmonth = incubatormvs.stream().collect(Collectors.groupingBy(i -> i.getInputTime().substring(0, 10)));
            List<String> daylist = EquipmentRecordServiceImplUtil.timeDifferenceCount(startdate, enddate);
            HashMap<String, List<IncubModel>> map = new HashMap<>();
            for (int i = 0; i < daylist.size(); i++) {
                //循环多少次,新建多少个list模型
                List<IncubModel> incubModelList = new ArrayList<>();
                String day = daylist.get(i);
                for (int j = 0; j < 4; j++) {
                    IncubModel incubModel = new IncubModel();
                    incubModel.setTime_interval((j + 1) + "");
                    incubModelList.add(incubModel);
                }
                //通过培养箱的天作为键,获取对应的list<IncubModel>,判断其是否为空,为空,则返回前端的是一个培养箱名键,值为空,如果不为空,
                //则说明,此培养箱有相应的数据
                List<Incubatormv> incubatormvslist = collectmonth.get(day);
                if (CollectionUtils.isNotEmpty(incubatormvslist)) {
                    for (int n = 0; n < incubatormvslist.size(); n++) {
                        //遍历取出原始数据模型
                        Incubatormv incubatormv = incubatormvslist.get(n);
                        //取出设备属性id判断是否为第三方数据
                        String instrumentTypeId = incubatormv.getInstrumentTypeId();
                        //如果设备属性instrumentTypeId为14,表明是设备自身数据
                        if (instrumentTypeId.equals("14") || instrumentTypeId.equals("13") || instrumentTypeId.equals("12") || instrumentTypeId.equals("97")
                                || instrumentTypeId.equals("105")) {

                            String timeIntervalz = incubatormv.getTimeInterval();
                            for (int m = 0; m < 4; m++) {
                                String time_interval = incubModelList.get(m).getTime_interval();
                                if (time_interval.equals(timeIntervalz)) {
                                    incubModelList.get(m).setMeanValue(incubatormv.getMeanValue());
                                    incubModelList.get(m).setHumidityMv(incubatormv.getHumidityMv());
                                    incubModelList.get(m).setCdMv(incubatormv.getCdMv());
                                    incubModelList.get(m).setOxygenMv(incubatormv.getOxygenMv());
                                }
                            }
                        }
                        //如果设备属性为1,表明数据为第三方MT100的
                        if (instrumentTypeId.equals("1") || instrumentTypeId.equals("2")) {
                            String thirdTimeIntervalMT100 = incubatormv.getThirdTimeInterval();
                            for (int m = 0; m < 4; m++) {
                                String time_interval = incubModelList.get(m).getTime_interval();
                                if (time_interval.equals(thirdTimeIntervalMT100)) {
                                    incubModelList.get(m).setEquipment_no(incubatormv.getEquipmentNo());
                                    incubModelList.get(m).setThirdTemperatureMvMT100(incubatormv.getThirdTemperatureMv());
                                }
                            }
                        }
                        if (instrumentTypeId.equals("4") || instrumentTypeId.equals("5") || instrumentTypeId.equals("6") || instrumentTypeId.equals("7")) {
                            //如果设备睡醒为3,表明数据为第三方MT300的
                            String thirdTimeIntervalMt300 = incubatormv.getThirdTimeInterval();
                            for (int m = 0; m < 4; m++) {
                                String time_interval = incubModelList.get(m).getTime_interval();
                                if (time_interval.equals(thirdTimeIntervalMt300)) {
                                    incubModelList.get(m).setThirdTemperatureMvMT300(incubatormv.getThirdTemperatureMv());
                                    incubModelList.get(m).setThirdCdMv(incubatormv.getThirdCdMv());
                                    incubModelList.get(m).setThirdYqMv(incubatormv.getThirdYqMv());
                                }
                            }
                        }
                    }
                }
                map.put(day, incubModelList);
            }
            return map;

    }



    @Override
    public void getIncBydayData(String day,String eqNo) {
        String beforeZero;
        if (StringUtils.isEmpty(day)) {
            beforeZero = DateUtil.getBeforeZero();
        } else {
            beforeZero = day;
        }
        for (int i = 1; i <= 4; i++) {
            String addAfterTime1 = DateUtil.getAddAfterTime(beforeZero, (i - 1) * 6);
            String addAfterTime = DateUtil.getAddAfterTime(beforeZero, i * 6);
            String currentYearMonth = DateUtil.getCurrentYearMonth();

            String tableName = "monitorequipmentlastdata" +currentYearMonth;
            List<Incubatormv> incubBydate = incubatormvMapper.getIncubByDaydate(tableName,addAfterTime1, addAfterTime,eqNo);
            log.info("时间段1:{}时间段2:{}培养箱拉取的数据:{}",addAfterTime1,addAfterTime,JSONObject.toJSON(incubBydate));
            Map<String, List<Incubatormv>> collect = incubBydate.stream().collect(Collectors.groupingBy(Incubatormv::getEquipmentNo));
            Set<String> strings = collect.keySet();
            List<Incubatormv> list = new ArrayList<>();
            int finalI = i;
            strings.forEach(s -> {
                List<Incubatormv> incubatormvs = collect.get(s);
                if (CollectionUtils.isNotEmpty(incubatormvs)) {
                    Incubatormv incubatormv = incubatormvs.get(0);
                    Incubatormv incubatormv1 = new Incubatormv();
                    incubatormv1.setEquipmentTypeId("2");
                    incubatormv1.setEquipmentNo(incubatormv.getEquipmentNo());
                    incubatormv1.setEquipmentName(incubatormv.getGroup());
                    String equipmentTypeId = incubatormv.getInstrumentTypeId();
                    incubatormv1.setInstrumentTypeId(equipmentTypeId);
                    incubatormv1.setInputTime(addAfterTime1);
                    //MT100
                    if (StringUtils.equalsAny(equipmentTypeId, "1", "2")) {
                        incubatormv1.setThirdTimeInterval(String.valueOf(finalI));
                        List<Incubatormv> collect1 = incubatormvs.stream().filter(m ->StringUtils.isNotEmpty(m.getCurrenttemperature())&&!StringUtils.equalsAnyIgnoreCase(m.getCurrenttemperature(), "0", "A", "B", "C", "D")).collect(Collectors.toList());
                        if (CollectionUtils.isNotEmpty(collect1)) {
                            collect1.forEach(m -> {
                                String currenttemperature = m.getCurrenttemperature();
                                m.setThirdTemperatureMv(Double.valueOf(currenttemperature));
                            });
                            double sum = collect1.stream().mapToDouble(Incubatormv::getThirdTemperatureMv).sum();
                            if (sum!=0) {
                                double divide = DateUtil.divide(sum, (double) collect1.size(), 2);
                                incubatormv1.setThirdTemperatureMv(divide);
                            }else {
                                incubatormv1.setThirdTemperatureMv(0.0);
                            }
                        }
                    }//MT300
                    else if (StringUtils.equalsAny(equipmentTypeId, "4", "5", "6", "7")) {
                        incubatormv1.setThirdTimeInterval(String.valueOf(finalI));
                        List<Incubatormv> collect1 = incubatormvs.stream().filter(m ->StringUtils.isNotEmpty(m.getCurrenttemperature())&&!StringUtils.equalsAnyIgnoreCase(m.getCurrenttemperature(), "0", "A", "B", "C", "D")).collect(Collectors.toList());
                        if (CollectionUtils.isNotEmpty(collect1)) {
                            collect1.forEach(m -> {
                                String currenttemperature = m.getCurrenttemperature();
                                m.setThirdTemperatureMv(Double.valueOf(currenttemperature));
                            });
                            double sum = collect1.stream().mapToDouble(Incubatormv::getThirdTemperatureMv).sum();
                            if (sum!=0) {
                                double divide = DateUtil.divide(sum, (double) collect1.size(), 2);
                                incubatormv1.setThirdTemperatureMv(divide);
                            }else {
                                incubatormv1.setThirdTemperatureMv(0.0);
                            }
                        }
                        List<Incubatormv> collect2 = incubatormvs.stream().filter(m ->StringUtils.isNotEmpty(m.getCurrentcarbondioxide())&&!StringUtils.equalsAnyIgnoreCase(m.getCurrentcarbondioxide(), "0", "A", "B", "C", "D")).collect(Collectors.toList());
                        if (CollectionUtils.isNotEmpty(collect2)) {
                            collect2.forEach(n -> {
                                String currentcarbondioxide = n.getCurrentcarbondioxide();
                                n.setThirdCdMv(Double.valueOf(currentcarbondioxide));
                            });
                            double sum1 = collect2.stream().mapToDouble(Incubatormv::getThirdCdMv).sum();
                            if (sum1!=0) {
                                double divide = DateUtil.divide(sum1, (double) collect2.size(), 2);
                                incubatormv1.setThirdCdMv(divide);
                            }else {
                                incubatormv1.setThirdCdMv(0.0);
                            }
                        }
                        List<Incubatormv> collect3 = incubatormvs.stream().filter(m ->StringUtils.isNotEmpty(m.getCurrento2())&&!StringUtils.equalsAnyIgnoreCase(m.getCurrento2(), "0", "A", "B", "C", "D")).collect(Collectors.toList());
                        if (CollectionUtils.isNotEmpty(collect3)) {
                            collect3.forEach(n -> {
                                String currento2 = n.getCurrento2();
                                n.setThirdYqMv(Double.valueOf(currento2));
                            });
                            double sum2 = collect3.stream().mapToDouble(Incubatormv::getThirdYqMv).sum();
                            if (sum2!=0) {
                                double divide = DateUtil.divide(sum2, (double) collect3.size(), 2);
                                incubatormv1.setThirdYqMv(divide);
                            }else {
                                incubatormv1.setThirdYqMv(0.0);
                            }
                        }
                    }//MT700 G185单独判断
                    else {
                        incubatormv1.setTimeInterval(String.valueOf(finalI));
                        List<Incubatormv> collect1;
                        if (StringUtils.equals(equipmentTypeId, "14")) {
                            collect1 = incubatormvs.stream().filter(m ->StringUtils.isNotEmpty(m.getCurrenttemperature1())&&!StringUtils.equalsAnyIgnoreCase(m.getCurrenttemperature1(), "0", "A", "B", "C", "D")).collect(Collectors.toList());
                            if (CollectionUtils.isNotEmpty(collect1)) {
                                collect1.forEach(m -> {
                                    String currenttemperature1 = m.getCurrenttemperature1();
                                    m.setMeanValue(Double.valueOf(currenttemperature1));
                                });
                            }
                        } else {
                            collect1 = incubatormvs.stream().filter(m ->StringUtils.isNotEmpty(m.getCurrenttemperature())&&!StringUtils.equalsAnyIgnoreCase(m.getCurrenttemperature(), "0", "A", "B", "C", "D")).collect(Collectors.toList());
                            if (CollectionUtils.isNotEmpty(collect1)) {
                                collect1.forEach(m -> {
                                    String currenttemperature = m.getCurrenttemperature();
                                    m.setMeanValue(Double.valueOf(currenttemperature));
                                });
                            }
                        }
                        if (CollectionUtils.isNotEmpty(collect1)) {
                            double sum = collect1.stream().mapToDouble(Incubatormv::getMeanValue).sum();
                            if (sum!=0) {
                                double divide = DateUtil.divide(sum, (double) collect1.size(), 2);
                                incubatormv1.setMeanValue(divide);
                            }else {
                                incubatormv1.setMeanValue(0.0);
                            }
                        }
                        List<Incubatormv> collect2 = incubatormvs.stream().filter(m ->StringUtils.isNotEmpty(m.getCurrentcarbondioxide())&&!StringUtils.equalsAnyIgnoreCase(m.getCurrentcarbondioxide(), "0", "A", "B", "C", "D")).collect(Collectors.toList());
                        if (CollectionUtils.isNotEmpty(collect2)) {
                            collect2.forEach(n -> {
                                String currentcarbondioxide = n.getCurrentcarbondioxide();
                                n.setCdMv(Double.valueOf(currentcarbondioxide));
                            });
                            double sum1 = collect2.stream().mapToDouble(Incubatormv::getCdMv).sum();
                            if (sum1!=0) {
                                double divide = DateUtil.divide(sum1, (double) collect2.size(), 2);
                                incubatormv1.setCdMv(divide);
                            }else {
                                incubatormv1.setCdMv(0.0);
                            }
                        }
                        List<Incubatormv> collect3 = incubatormvs.stream().filter(m ->StringUtils.isNotEmpty(m.getCurrento2())&&!StringUtils.equalsAnyIgnoreCase(m.getCurrento2(), "0", "A", "B", "C", "D")).collect(Collectors.toList());
                        if (CollectionUtils.isNotEmpty(collect3)) {
                            collect3.forEach(n -> {
                                String currento2 = n.getCurrento2();
                                n.setOxygenMv(Double.valueOf(currento2));
                            });
                            double sum2 = collect3.stream().mapToDouble(Incubatormv::getOxygenMv).sum();
                            if (sum2!=0) {
                                double divide = DateUtil.divide(sum2, (double) collect3.size(), 2);
                                incubatormv1.setOxygenMv(divide);
                            }else {
                                incubatormv1.setOxygenMv(0.0);
                            }
                        }
                        List<Incubatormv> collect4 = incubatormvs.stream().filter(m ->StringUtils.isNotEmpty(m.getCurrenthumidity())&&!StringUtils.equalsAnyIgnoreCase(m.getCurrenthumidity(), "0", "A", "B", "C", "D")).collect(Collectors.toList());
                        if (CollectionUtils.isNotEmpty(collect4)) {
                            collect4.forEach(n -> {
                                String currenthumidity = n.getCurrenthumidity();
                                n.setHumidityMv(Double.valueOf(currenthumidity));
                            });
                            double sum3 = collect4.stream().mapToDouble(Incubatormv::getHumidityMv).sum();
                            if (sum3!=0) {
                                double divide = DateUtil.divide(sum3, (double) collect4.size(), 2);
                                incubatormv1.setHumidityMv(divide);
                            }else {
                                incubatormv1.setHumidityMv(0.0);
                            }
                        }
                    }
                    list.add(incubatormv1);
                }
            });
            saveBatch(list);
        }
    }

    @Override
    public Map<String, List<IncubModel>>    selectIncubdayNew(String date) {
        //从数据库查询出当天所有培养箱的,MT700(自身数据),第三方(MT300,mt100),返回一个list集合
        List<Incubatormv> listincub = incubatormvMapper.selectIncubday(date);
        //过滤掉名字为空的
        List<Incubatormv> collect = listincub.stream().filter(s -> StringUtils.isNotEmpty(s.getEquipmentName())).collect(Collectors.toList());
        //将查询到的所有数据进行名称分组.例如,13号培养箱包含(MT700,MT300,MT100),得到一个map<培养箱名称,培养箱模型>集合          //如若修改,可将此修改为getgroup分组,效果一样
        Map<String, List<Incubatormv>> collectIncoub = collect.stream().collect(Collectors.groupingBy(Incubatormv::getEquipmentName));
        HashMap<String, List<IncubModel>> map = new HashMap<>();
        //获得所有培养箱名称集合
        Collection key = collectIncoub.keySet();
        //将key放入list集合中方便取值
        List<String> list1 = new ArrayList<>(key);

        for (int i = 0; i < list1.size(); i++) {
            //循环一次建立一个List<IncubModel>
            List<IncubModel> list = new ArrayList<>();
            //获取到质控设备id,例如 : 13,作为新map的键
            String incubName = list1.get(i);
            //一个培养箱名称,对应的list里面有四个培养箱模型,所以循环四次
            for (int j = 0; j < 4; j++) {
                //每循环一次创建一个新的培养箱模型  ·
                IncubModel incubModel = new IncubModel();
                //每循环一次设置时间区间,一共四个区间,时间区间为共有属性
                incubModel.setTime_interval((j + 1) + "");
                list.add(incubModel);
            }
            //通过培养箱的名字作为键,获取对应的list<IncubModel>,判断其是否为空,为空,则返回前端的是一个培养箱名键,值为空,如果不为空,
            //则说明,此培养箱有相应的数据
            List<Incubatormv> incubatormvslist = collectIncoub.get(incubName);
            if (CollectionUtils.isNotEmpty(incubatormvslist)) {
                for (int n = 0; n < incubatormvslist.size(); n++) {
                    //遍历取出原始数据模型
                    Incubatormv incubatormv = incubatormvslist.get(n);
                    //取出设备属性id判断是否为第三方数据
                    String instrumentTypeId = incubatormv.getInstrumentTypeId();
                    //如果设备属性instrumentTypeId为14,13,12,97表明是设备自身数据
                    if (StringUtils.equalsAnyIgnoreCase(instrumentTypeId, "12","14","105","13","100","97","100","101","105","111","115","117")) {
                        String timeIntervalz = incubatormv.getTimeInterval();
                        for (int m = 0; m < 4; m++) {
                            String time_interval = list.get(m).getTime_interval();
                            if (time_interval.equals(timeIntervalz)) {
                                list.get(m).setMeanValue(incubatormv.getMeanValue());
                                list.get(m).setHumidityMv(incubatormv.getHumidityMv());
                                list.get(m).setCdMv(incubatormv.getCdMv());
                                list.get(m).setOxygenMv(incubatormv.getOxygenMv());
                            }
                        }
                    }
                    //如果设备属性为1,表明数据为第三方MT100的
                    if (StringUtils.equalsAny(instrumentTypeId, "1", "2","113")) {
                        String thirdTimeIntervalMT100 = incubatormv.getThirdTimeInterval();
                        for (int m = 0; m < 4; m++) {
                            String time_interval = list.get(m).getTime_interval();
                            if (time_interval.equals(thirdTimeIntervalMT100)) {
                                list.get(m).setThirdTemperatureMvMT100(incubatormv.getThirdTemperatureMv());
                                list.get(m).setEquipment_no(incubatormv.getEquipmentNo());
                            }
                        }
                    }
                    if (StringUtils.equalsAny(instrumentTypeId, "4", "5", "6", "7", "109","102","108","109","110","112")) {
                        //如果设备睡醒为3,表明数据为第三方MT300的
                        String thirdTimeIntervalMt300 = incubatormv.getThirdTimeInterval();
                        for (int m = 0; m < 4; m++) {
                            String time_interval = list.get(m).getTime_interval();
                            if (time_interval.equals(thirdTimeIntervalMt300)) {
                                list.get(m).setThirdTemperatureMvMT300(incubatormv.getThirdTemperatureMv());
                                list.get(m).setThirdCdMv(incubatormv.getThirdCdMv());
                                list.get(m).setThirdYqMv(incubatormv.getThirdYqMv());
                            }
                        }
                    }

                }
            }
            map.put(incubName, list);
        }
        return map;
    }

}
